/**
 * Created by DukeCrushIt on 2015/8/12.
 */
class PanelContainer extends eui.Component{
    public constructor(){
        super();
        this.skinName = "pet.PanelContainerSkin";
    }

    private curScene:number = -1;
    public showPanel(scene:number){
        if( this.curScene == scene )
            return;
            while(this.panel_group.numChildren)
                this.panel_group.removeChildAt(0);
        //this.updateBigDataTitle(-1);
        switch (scene){
            case SceneMgr.SCENE_TRAVEL:
                this.panel_group.addChild(TravelPanel.getInstance());
                this.img_title.source = RES.getRes("img_petshop_txt");
                break;
            case SceneMgr.SCENE_SHOP:
                this.panel_group.addChild(PetShopScene.getInstance());
                this.img_title.source = RES.getRes("img_shop_txt");
                break;
            case SceneMgr.SCENE_DATA:
                this.panel_group.addChild(BigdataScene.getInstance());
                break;
            case SceneMgr.SCENE_ACTIVITY:
                this.panel_group.addChild(ActivityPanel.getInstance());
                this.img_title.source = RES.getRes("img_title_activity");
                break;
        }
        if( this.img_title.source)
            this.img_title.x = 480 - this.img_title.width  >> 1;
        this.curScene = scene;
    }
    private dataTitles:string[] = ["motherfucker_13","motherfucker_11","motherfucker_2","GDP","title_forbes","motherfucker_6"];
    public updateBigDataTitle(page:number){
        if( page != -1){
            this.img_title.source = RES.getRes(this.dataTitles[page]);
            this.img_title.x = 480 - this.img_title.width  >> 1;
        }
    }

    public img_bg:eui.Image;
    public img_title:eui.Image;
    public panel_group:eui.Group;
    public partAdded(name:string, instance:any){
        if(name == "img_bg"){
            this.img_bg = instance;
        }else if( name == "panel_group"){
            this.panel_group = instance;
        }else if( name == "img_title"){
            this.img_title = instance;
        }
    }

    public createChildren(){
        super.createChildren();
        this.y = 65;
    }
    private static _instance:PanelContainer;
    public static getInstance():PanelContainer{
        if( PanelContainer._instance == null)
            PanelContainer._instance = new PanelContainer();
        return PanelContainer._instance;
    }
}